import {
    getResumeLists,
    getResumeDetailInfo,
    getSelectResumeLists,
    getResumeSelectDetailInfo,
    saveResumeInfo,
    delDetailUploadFileByPath
} from '../../fetch/modules/resume'
import { removeTempFiles } from './../../fetch/modules/common'

const state = {
    resumeLists: {
    },
    resumeDetailInfo: {},
    selectResumeLists: {},
    selectResDetailInfo: {},
    saveInfo: {},
    delInfo: {}
}

const actions = {
    FETCH_RESUMES: ({ commit, state }, opts) => {
        console.log(opts)
        return getResumeLists(opts).then(resume => commit('GET_RESUME_LISTS', { resume }))
    },
    FETCH_RESUME_DETAIL_INFO: ({ commit, state }, opts) => {
        return getResumeDetailInfo(opts).then(resume => commit('GET_RESUME_DETAIL_INFO', { resume }))
    },
    FETCH_SELECT_RESUMES: ({ commit, state }, opts) => {
        return getSelectResumeLists(opts).then(resume => commit('FETCH_RESUME_LIST_INFO', { resume }))
    },
    FETCH_RESUME_BYID: ({ commit, state }, opts) => {
        return getResumeSelectDetailInfo(opts).then(resume => commit('FETCH_RESUME_SELECT_BYID', { resume }))
    },
    FETCH_SAVE_RESUME_INFO: ({ commit, state }, opts) => {
        return saveResumeInfo(opts).then(resume => commit('SAVE_RESUME_INFO', { resume }))
    },
    DEL_RESUME_DETAIL: ({ commit, state }, opts) => {
        return removeTempFiles(opts).then(resume => commit('DELETE_RESUME_INFO', { resume }))
    },
    /* DEL_RESUME_DETAIL: ({ commit, state }, opts) => {
        return delDetailUploadFileByPath(opts).then(resume => commit('DELETE_RESUME_INFO', { resume }))
    }, */
}
const mutations = {
    GET_RESUME_LISTS: (state, { resume }) => {
        state.resumeLists = resume.data;
    },
    GET_RESUME_DETAIL_INFO: (state, { resume }) => {
        state.resumeDetailInfo = resume.data;
    },
    FETCH_RESUME_LIST_INFO: (state, { resume }) => {
        state.selectResumeLists = resume.data;
    },
    FETCH_RESUME_SELECT_BYID: (state, { resume }) => {
        state.selectResDetailInfo = resume.data;
    },
    SAVE_RESUME_INFO: (state, { resume }) => {
        state.saveInfo = resume.data;
    },
    DELETE_RESUME_INFO: (state, { resume }) => {
        state.delInfo = resume.data;
    },
}

const getters = {
    getResumeLists(state) {
        return state.resumeLists
    },
    getResumeDetailInfo(state) {
        return state.resumeDetailInfo
    },
    getSelectResumeLists(state) {
        return state.selectResumeLists
    },
    getSelectResumeLDetail(state) {
        return state.selectResDetailInfo
    },
    getSaveResumeInfo(state) {
        return state.saveInfo
    },
    getDelResumeInfo(state) {
        return state.delInfo
    }
}

export default {
    state,
    actions,
    mutations,
    getters
}